package acm.pta15;

import java.util.*;

//todo：珂朵莉树有望
public class 静静的推荐 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int line = sc.nextInt();
        Store store = new Store(line);
        for (int i = 0; i < n; i++) {
            int pta = sc.nextInt();
            int score = sc.nextInt();
            store.add(pta, score);
        }
        int res = 0;
        for (int i = 0; i < k; i++) {
            if (store.isEmpty()) {
                break;
            }
            res += store.select();
        }
        System.out.println(res);
    }

    public static class Store {
        TreeMap<Integer, Integer>[] set = new TreeMap[116];  //每个分数学生的pta分数
        int size = 0;
        int line; //分数线

        public Store(int line) {
            this.line = line;
            for (int i = 0; i < set.length; i++) {
                set[i] = new TreeMap<>();
            }
        }

        public void add(int score, int pta) {
            if (score < 175) return;
            set[score - 175].merge(pta, 1, Integer::sum);
            size++;
        }

        public int select() {  //选拔
            int res = 0;
            for (TreeMap<Integer, Integer> tree : set) {
                if (!tree.isEmpty()) {
                    tree.merge(tree.firstKey(), -1, Integer::sum);
                    if (tree.get(tree.firstKey()) == 0) {
                        tree.remove(tree.firstKey());
                    }
                    NavigableMap<Integer, Integer> pass = tree.tailMap(line, true);
                    for (Map.Entry<Integer, Integer> o : pass.entrySet()) {
                        res += o.getValue();
                        size -= o.getValue();
                    }
                    size--;
                    res++;
                    pass.clear();
                }
            }
            return res;
        }

        public boolean isEmpty() {
            return size == 0;
        }
    }
}
